package com.cn.wanxi.test;

import java.util.Random;

public class RandomArray {
    public static void main(String[] args) {
        /**
         * 1.定义数组
         * 2.定义随机数
         * 3.赋值给数组
         * 4.最大值
         */
        int[] arr = new int[10];
        createArray(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }


        reMethod(arr);

        System.out.println();
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            max = max > arr[i] ? max : arr[i];
        }
        System.out.println(max);
    }

    private static void reMethod(int[] arr) {
        int[] aa = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            aa[i] = arr[arr.length - i - 1];
        }
    }

    private static void createArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            Random random = new Random();
//            取[m，n]之间的随机数
//            random.nextInt(n-m+1) + m;
            arr[i] = random.nextInt(100) + 1;
        }

    }

}
